package cn.com.utt.common.message;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;

public class Command extends Message {
	@JSONField(name="replyto") 
	private String replyTo;
	@JSONField(name="timeout") 
	private int timeout;
	@JSONField(name="commands") 
	private String[] commands;
	
	public Command() {
		setType(MessageType.COMMAND.toString());
	}

	@Override
	public String encode() {
		return JSON.toJSONString(this);
	}

	@Override
	public void decode(byte[] buf) {
		Command command = JSON.parseObject(buf, Command.class);
		this.setId(command.getId());
		this.replyTo = command.getReplyTo();
		this.timeout = command.getTimeout();
		this.commands = command.getCommands();
	}

	public String getReplyTo() {
		return replyTo;
	}

	public void setReplyTo(String replyTo) {
		this.replyTo = replyTo;
	}

	public int getTimeout() {
		return timeout;
	}

	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}

	public String[] getCommands() {
		return commands;
	}

	public void setCommands(String[] commands) {
		this.commands = commands;
	}

}
